package com.example.yang.samapp;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
 * Created by Yang on 2016/9/19.
 */
public class basketball_btn_zuile extends AppCompatActivity{
    private Button button;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.absketball);
        button=(Button) findViewById(R.id.basketball_btn);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new CountDownThread(10).start();
                button.setEnabled(false);

            }
        });

    }
    class CountDownThread extends CountDownTimer{
        private int seconds;
            public CountDownThread(int secondsInfuture){
                super(secondsInfuture*1000,1000);
                seconds=secondsInfuture;
            }


        @Override
        public void onTick(long millisUntilFinished) {

            button.setText("已发送"+seconds+"s");
            seconds--;

        }

        @Override
        public void onFinish() {
            button.setText("重新发送");
            button.setEnabled(true);
        }
    }
}
